<template>
  <div>
    <el-cascader
      v-model="value"
      :options="options"
      clearable
      :props="{value: 'id', label: 'name'}"
      @change="handleChange"
    />
  </div>
</template>

<script>
import { departmentRequest, transformListToTree } from '@/api/department'

export default {
  name: '',
  data() {
    return {
      value: '',
      options: []
    }
  },
  created() {
    this.companyDepartmen()
  },
  methods: {
    handleChange(value) {
      console.log(value)
    },
    // 获取部门列表
    async companyDepartmen() {
      const res = await departmentRequest()
      this.options = transformListToTree(res.data, 0)
      console.log(this.options)
    }
  }
}
</script>
